import {App, Component, Plugin} from "vue"

/**
 * 生成全局注册组件库中所有组件的插件
 *
 * @param {Record<string, Component>} componentsMap 组件库中所有组件与其组件名的映射 Map
 * @returns {Plugin} 全局注册组件库中所有组件的插件
 */
export const genCompLibGlobalRegisterPlugin = (componentsMap: Record<string, Component>): Plugin => {
  return (app: App): App => {
    for (let componentName in componentsMap) {
      app.component(componentName, componentsMap[componentName])
    }
    return app
  }
}
